#include "comm.hpp"


int main()
{
    int shmid = GetShm();
    char* shmaddr = (char*)shmat(shmid, nullptr, 0);

    int fd = open(FIFO_FILE, O_WRONLY);
    if(fd < 0)
    {
        log(Fatal, "failed to open file, error string: %s, error code: %d", strerror(errno), errno);
        exit(FIFO_OPEN_ERR);
    }

    // IPC code
    while(true)
    {
        cout << "Please Enter# ";
        fgets(shmaddr, 4096, stdin);

        write(fd, "c", 1); // 通知接收方，是双方数据同步
    }

    shmdt(shmaddr);

    close(fd);

    return 0;
}